<?php
$updateCaptcha = <<<EOD
function(form,attribute,data,hasError) {
    jQuery('#yw0_button').click();
    return true;
}
EOD;
?>
<?php 
$this->layout = "//layouts/column1"; 
$this->pageTitle = Yii::app()->name . ' - Signup';
?>
<h1>Sign Up</h1>
<div class="form" style="">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'member-form',
        'enableAjaxValidation' => true,
        'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
            'validateOnChange' => true,
            'afterValidateAttribute' => 'js:' . $updateCaptcha,
            'afterValidate' => 'js:' . $updateCaptcha,
        ),
            ));
    ?>
    <div class="signup-section"> 
        <p class="note">Fields with <span class="required">*</span> are required......</p>
        <?php echo $form->errorSummary($model); ?>
        <div class="row">
            <?php echo $form->labelEx($model, 'first_name'); ?>
            <?php echo $form->textField($model, 'first_name', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'first_name'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'last_name'); ?>
            <?php echo $form->textField($model, 'last_name', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'last_name'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'email'); ?>
            <?php echo $form->textField($model, 'email', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'email'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'username'); ?>
            <?php echo $form->textField($model, 'username', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'username'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'password'); ?>
            <?php echo $form->passwordField($model, 'password', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'password'); ?>
        </div>
        <div class="row"> 
            <?php echo $form->labelEx($model, 'password_repeat'); ?> 
            <?php echo $form->passwordField($model, 'password_repeat', array('size' => 30, 'maxlength' => 255)); ?> 
            <?php echo $form->error($model, 'password_repeat', array('class' => 'alert alert-error')); ?> 
        </div> 
        <div class="row">
            <?php echo $form->labelEx($model, 'security_question_id'); ?>		
            <?php 
            $sqList = SecurityQuestion::model()->findAll();
            $sqArr = CHtml::listData($sqList, 'secutiry_question_id', 'question');
            echo $form->dropDownList($model, 'security_question_id', $sqArr, array('empty' => 'Select a security question...')); ?>
            <?php echo $form->error($model, 'security_question_id'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'security_answer'); ?>
            <?php echo $form->textField($model, 'security_answer', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'security_answer'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'security_code'); ?>
            <?php echo $form->textField($model, 'security_code', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'security_code'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'ego_pay'); ?>
            <?php echo $form->textField($model, 'ego_pay', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'ego_pay'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'perfect_money'); ?>
            <?php echo $form->textField($model, 'perfect_money', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'perfect_money'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'upline'); ?>
            <?php echo $form->textField($model, 'upline', array('size' => 30, 'maxlength' => 255)); ?>
            <?php echo $form->error($model, 'upline'); ?>
        </div>
        <div class="row agree">
            <?php echo $form->labelEx($model, 'member_type'); ?>
            <?php echo $form::dropDownList($model, 'member_type', array('A' => 'A', 'B' => 'B'), array('empty' => '---Select a type---', "disabled"=>($model->member_type == 'A' || $model->member_type == 'B')?"disabled":''));?>
            <?php echo $form->error($model, 'member_type'); ?>
        </div>
        <div class="row agree">
            <?php echo $form->labelEx($model, 'package_id'); ?>
            <?php
            $packageList = CHtml::listData(Package::model()->findAll(), 'package_id', 'name');
            echo $form->dropDownList($model, 'package_id', $packageList, array(
                'empty' => '---Select Package---',
            ));
            ?>
        <?php echo $form->error($model, 'package_id'); ?>
        </div>
        <div class="row">
            <?php echo $form->labelEx($model, 'paymentmethod_id'); ?>
            <?php
            //$sql = "select * from payment_processor where status = '1'";
            //$_lh = Yii::app()->db->createCommand($sql)->queryAll();
            
            $criteria = new CDbCriteria();
            $criteria->condition = "status = '1'";
            $criteria->order = 'payment_processors_id DESC';
            $methodList = CHtml::listData(PaymentProcessor::model()->findAll($criteria), 'code', 'name');
            //$list = CHtml::listData($_lh, 'code', 'name');
            echo $form->dropDownList($model, 'paymentmethod_id', $methodList, array(
                'empty' => '---Select Payment Method---',
            ));
            ?>
            <?php echo $form->error($model, 'paymentmethod_id'); ?>
        </div>
        <div class="row agree">
            <?php echo $form->labelEx($model, 'agree_to_tos'); ?>
            <?php echo $form->checkBox($model, 'agree_to_tos', array('size' => 1, 'maxlength' => 1)); ?>
            <?php echo $form->error($model, 'agree_to_tos'); ?>
        </div>
        <?php if (CCaptcha::checkRequirements()): ?>
            <div class="row captcha">
                <?php echo $form->labelEx($model, 'verifyCode'); ?>
                <div>
                    <?php $this->widget('CCaptcha'); ?>
                    <?php echo $form->textField($model, 'verifyCode'); ?>
                </div>
                <div class="hint">Please enter the letters as they are shown in the image above.
                    <br/>Letters are not case-sensitive.</div>
                <?php echo $form->error($model, 'verifyCode'); ?>
            </div>
        <?php endif; ?>
        <div class="row buttons">
            <?php echo CHtml::submitButton('Register'); ?>
        </div>
    </div>
    <?php $this->endWidget(); ?>
</div>